const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const { rootPath } = require('../utils');
const dllPath = rootPath('src/assets/dll'); // dll文件存放的目录

module.exports = {
    mode: 'production',
    entry: {
        vendor: [
            'react',
            'react-dom',
            'mobx',
            'mobx-react',
            'react-router-dom',
            'axios',
            'lodash',
        ],
    },

    output: {
        path: dllPath,
        filename: '[name]-[hash:5].dll.js',
        library: '_dll_[name]',
    },

    plugins: [
        new CleanWebpackPlugin(),
        new webpack.DllPlugin({
            name: '_dll_[name]',
            // manifest.json 描述动态链接库包含了哪些内容
            path: rootPath('src/assets/dll/[name].dll.manifest.json')
        }),
    ]
};